<?php
	$usr = new User_subscribe();
	if(isset($_POST['user_name'])){
		$usr_info = $usr->saveUserDetail();		
	}
?>	
<div class="span3 right_container">		
	
	<div class="right_blog_container">
		<div class="right_blog_header">
			<div><h3 class="uiHeaderTitle">Subscribe Panel</h3></div>
		</div>
		<div class="right_blog_content">
			
			<?php 
				if(isset($usr_info) && trim($usr_info)!=''){											
			?>
			<div class="alert alert-error">
				<div style="float: right; width: 5%;"><button type="button" class="close" data-dismiss="alert">&times;</button></div>
				<div style="float:left;width: 92%;word-wrap: break-word;"><?php echo $usr_info; ?></div>
				<div style="clear:both;"></div>							
			</div>
			<?php
				}
			?>
			<!--<h4 class="title"><span class="text"><strong>SUBSCRIBE</strong> Form</span></h4>-->			
			<form action="<?php echo $_SERVER['PHP_SELF']; ?>?home=1" method="POST" name="email_subscribe" >
				<input type="hidden" name="next" value="/">
				<fieldset>
					<div class="control-group">
						<label class="control-label">Username</label>
						<div class="controls">
							<input type="text" placeholder="User Name" name="user_name" id="user_name" class="input-xlarge subs_width">
						</div>
					</div>
					<div class="control-group">
						<label class="control-label">Email</label>
						<div class="controls">
							<input type="text" name="user_email" id="user_email"  placeholder="Email" class="input-xlarge subs_width">
						</div>
					</div>
					<div class="control-group">
						<button tabindex="3" type="button" class="btn btn-inverse large subscribe_button">Subscribe</button> 
					</div>
				</fieldset>
			</form>
		</div>
	</div>

	<div class="right_blog_container">
		<div class="right_blog_header">
			<div><h3 class="uiHeaderTitle">Latest News</h3></div>
		</div>
		<div class="right_blog_content">
			Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
		</div>
	</div>

	<div id="fb-root"></div>
	<script type="text/javascript">
		 (function (d, s, id) {
			 var js, fjs = d.getElementsByTagName(s)[0];
			 if (d.getElementById(id)) return;
			 js = d.createElement(s); js.id = id;
			 js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
			 fjs.parentNode.insertBefore(js, fjs);
		 } (document, 'script', 'facebook-jssdk'));
	</script>
	<div class="fb_blog_container">
		<div class="fb-like-box" data-href="http://www.facebook.com/rvtrainingsolutions" data-width="200" data-height="300" data-show-faces="true" data-stream="false" data-border-color="black" data-header="true"></div>
	</div>	

</div>
<script>
	$ = jQuery.noConflict();
	$(document).ready(function(){	
		$('.subscribe_button').click(function(){
			if($('#user_name').val() == ''){			
				alert("Please enter a value for the \"User Name\" field.");
				$('#user_name').focus();
				return (false);
			}			
			else if($('#user_email').val() == "")
			{
				alert("Please enter a value for the \"Email\" field.");
				$('#user_email').focus();				
				return (false);
			}
			else if(($('#user_email').val().indexOf("\@") == -1) || ($('#user_email').val().indexOf(".")== -1) || isInvalidateEmail($('#user_email').val()))
			{
				alert("Invalid Email Address");
				$('#user_email').focus();
				return (false);
			}
			else
			{
				document.email_subscribe.submit();
			}

		});
		
	});

	function isInvalidateEmail(str)
	{
		var atpos=str.indexOf("@");
		var dotpos=str.lastIndexOf(".");
		if (atpos<1 || dotpos<atpos+2 || dotpos+2>=str.length)
		  {
		  return true;
		  }
		return false;
	}

</script>